<?php

namespace app\index\controller;

use app\api\model\Circle as CircleModel;
use app\api\model\Member as MemberModel;
use think\View;

class Member
{
    public $memberId;

    public function __construct()
    {
        $this->memberId = session('member_id');
        if (empty($memberId)) {
            header('Location: /index/index/index/');
        }
    }

    public function index()
    {
        // echo '这是登录后的界面';
        return View::fetch();
    }
    public function getList(){
        //分页 page 函数 limit
        $page = input('get.page');
        $data = CircleModel::page($page)->Limit(20)->order('circle_id desc')->select();
        $count = CircleModel::count();
        foreach ($data as $value) {
            $memberData = MemberModel::where('member_id', '=', $value['member_id'])
                ->field('member_nickname,member_avatar')->find();
            $memberData['member_avatar'] = URL_AVATAR . $memberData['member_avatar'];
            $value['member_avatar'] = $memberData['member_avatar'];
            $value['member_nickname'] = $memberData['member_nickname'];
            $value['add_time'] = date('Y年m月d日 H:i:s',$value['add_time']);
        }
        output_data_table($data,$count);
    }

}
